
# ifndef __DFX_MEMORY_FILE_H__
# define __DFX_MEMORY_FILE_H__

# include "dfxFile.h"

namespace DFX
{
    class DFX_EXPORT MemoryFile : public FileBase
    {
    protected:

        bool	    mOwnsBuffer;
        UInt64      mSize;
        const void*	mBuffer;

    public:

        MemoryFile()
            : mOwnsBuffer(false), mSize(0), mBuffer(NULL)
        {
        }

        virtual ~MemoryFile()
        {
            DeleteBuffer();
        }

        const UInt8* GetData() const
        {
            return reinterpret_cast<const UInt8*>(mBuffer);
        }

        UInt64 GetSize() const
        {
            return mSize;
        }

        void Create(UInt64 size);
        void CreateFromString(const String &string);
        void CreateFromBuffer(const void *buffer, UInt64 size);
        void CreateFromManagedBuffer(const void *buffer, UInt64 size);
        void DeleteBuffer();
    };
}

# endif